from django.shortcuts import render
from django.views import View
from django.conf import settings
from django.http import JsonResponse
from QQLoginTool.QQtool import OAuthQQ


class QQAuthURLView(View):
    def get(self, request):
        next = request.GET.get('next')
        client_id = settings.QQ_CLIENT_ID
        client_secret = settings.QQ_CLIENT_SECRET
        redirect_uri = settings.QQ_REDIRECT_URI
        oauth = OAuthQQ(client_id=client_id,
                        client_secret=client_secret,
                        redirect_uri=redirect_uri,
                        state=next)
        login_url = oauth.get_qq_url()

        return JsonResponse({'code': 0,
                             'errmsg': 'OK',
                             'login_url': login_url})


class QQAuthUserView(View):
    def get(self, request):
        pass
